package com.tn.controller.gate;

import com.tn.controller.alarm.common.model.CommonVO;
import com.tn.controller.alarm.common.model.PageInput;
import com.tn.controller.alarm.common.model.PageResult;
import com.tn.controller.alarm.common.model.gate.vo.GateLogInfoVO;
import com.tn.controller.alarm.common.model.gate.vo.GateLogQueryVO;
import com.tn.exception.InvalidParamException;
import com.tn.service.gate.IGateService;
import com.tn.utils.CheckParamUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 闸口controller
 *
 * @program: tn_aucy_java
 * @author: yangjiayao
 * @create: 2021/11/16
 */
@Slf4j
@RestController
@RequestMapping("/aucy")
public class GateController {

    @Resource
    private IGateService gateService;

    /**
     * 查询闸口当前信息
     *
     * @param queryVO 分页入参
     * @return 闸口当前信息
     * @throws InvalidParamException 异常
     */
    @RequestMapping("/currentGateInfo")
    public CommonVO<PageResult<GateLogInfoVO>> currentGateInfo(@RequestBody PageInput<GateLogQueryVO> queryVO)
            throws InvalidParamException {
        CheckParamUtil.checkPageParam(queryVO.getCurPage(), queryVO.getPageSize());
        return gateService.currentGateInfo(queryVO.getCurPage(), queryVO.getPageSize());
    }



    /**
     * 闸口修改车牌信息
     * @return
     */
    @PostMapping("/updateCurrentGateInfo")
    public CommonVO<Object> updateCurrentGateInfo(String gateId, String license) {
        return gateService.updateCurrentGateInfo(gateId, license);
    }
}
